﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XYZshell.Game.CardGameEngine
{
	public class ExpressionHelper
	{
		public static List<Type> AvailableExpression
		{
			get
			{
				List<Type> rtn= new List<Type>();
				rtn.Add( typeof( DirectValueExpression ) );
				rtn.Add( typeof( PropertyExpression ) );
				rtn.Add( typeof( EventExpression ) );
				return rtn;
			}
		}

		public static BaseCondition GetExpressionInstanceByID( string id )
		{

			return Activator.CreateInstance( GetExpressionByID( id ) ) as BaseCondition;

		}

		public static Type GetExpressionByID( string id )
		{
			foreach (Type t in AvailableExpression)
			{
				ExpressionAttribute ct= (ExpressionAttribute)t.GetCustomAttributes( typeof( ExpressionAttribute ), false )[0];
				if (ct.ID == id)
					return t;
			}
			return null;
		}
	}
}
